import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    // 重定向
    redirect: '/longinHome'
  },
  {
    path: '/home',
    name: 'Home',
    component: Home
  },
  // 发货单
  {
    path: '/deliverGoods',
    name: 'DeliverGoods',
    component: () => import(/* webpackChunkName: "deliverGoods" */ '../views/DeliverGoods.vue')
  },
  //  发货详情页
  {
    path: '/userImformation',
    name: 'UserImformation',
    component: () => import(/* webpackChunkName: "SendGoods" */ '../components/GoodsDescribe/UserImformation.vue')
  },
  //  评价
  {
    path: '/estimate',
    name: 'Estimate',
    component: () => import(/* webpackChunkName: "EvaluateInfo" */ '../components/GoodsDescribe/Estimate.vue')
  },
  // 登录页
  {
    path: '/loginPage',
    name: 'LoginPage',
    component: () => import(/* webpackChunkName: "LoginPage" */ '../components/LoginPage.vue')
  },


  // 消息中心
  {
    path: '/messageCenter',
    name: 'MessageCenter',
    component: () => import(/* webpackChunkName: "MessageCenter" */ '../views/MessageCenter.vue')
  },
  // 消息详情
  {
    path: '/messageDetail',
    name: 'messageDetail',
    component: () => import(/* webpackChunkName: "messageDetail" */ '../components/messageDetail.vue')
  },
  // 登录首页
  {
    path: '/longinHome',
    name: 'LonginHome',
    component: () => import(/* webpackChunkName: "messageDetail" */ '../components/LonginHome.vue')
  },
  // 个人中心页
  {
    path: '/personal',
    name: 'personal',
    component: () => import(/* webpackChunkName: "messageDetail" */ '../views/personal.vue')
  },
  // 个人中心详情页
  {
    path: '/personDetail',
    name: 'PersonDetail',
    component: () => import(/* webpackChunkName: "PersonDetail" */ '../components/PersonDetail.vue')
  },
  // 个人中心版本页
  {
    path: '/banben',
    name: 'Banben',
    component: () => import(/* webpackChunkName: "Banben" */ '../components/Banben.vue')
  },

  // 物流单
  {
    path: '/express',
    name: 'Express',
    component: () => import(/* webpackChunkName: "Express" */ '../views/Express.vue')
  },

   // 物流单评价
   {
    path: '/expresspj',
    name: 'expressPJ',
    component: () => import(/* webpackChunkName: "expressPJ" */ '../components/expressPJ.vue')
  },
  // 评价详情
  {
    path: '/expressDetail',
    name: 'ExpressDetail',
    component: () => import(/* webpackChunkName: "ExpressDetail" */ '../components/ExpressDetail.vue')
  },

  // 客户列表
  {
    path: '/myClients',
    name: 'MyClients',
    component: () => import(/* webpackChunkName: "MyClients" */ '../views/MyClients.vue')
  },

   // 客户详细信息
   {
    path: '/custmerDetail',
    name: 'CustmerDetail',
    component: () => import(/* webpackChunkName: "CustmerDetail" */ '../components/Cust/CustmerDetail.vue')
  },
  // 客户信息
  {
    path: '/custImformation',
    name: 'CustImformation',
    component: () => import(/* webpackChunkName: "CustImformation" */ '../components/Cust/CustImformation.vue')
  },
    // 编辑信息
    {
      path: '/edit',
      name: 'Edit',
      component: () => import(/* webpackChunkName: "Edit" */ '../components/Cust/Edit.vue')
    },
    //新增客户信息
    {
      path: '/addcust',
      name: 'Addcust',
      component: () => import(/* webpackChunkName: "Addcust" */ '../components/Cust/Addcust.vue')
    },
 //新增客户信息
 {
  path: '/visit',
  name: 'Visit',
  component: () => import(/* webpackChunkName: "Visit" */ '../components/Cust/Visit.vue')
},

 //新增拜访信息
 {
  path: '/NewAdd',
  name: 'NewAdd',
  // route level code-splitting
  // this generates a separate chunk (about.[hash].js) for this route
  // which is lazy-loaded when the route is visited.
  component: (resolve) => require([/* webpackChunkName: "NewAdd" */ '../components/Cust/NewAdd.vue'], resolve),
},
{
  path: '/Baifang',
  name: 'Baifang',
  // route level code-splitting
  // this generates a separate chunk (about.[hash].js) for this route
  // which is lazy-loaded when the route is visited.
  component: (resolve) => require([/* webpackChunkName: "Baifang" */ '../components/Cust/Baifang.vue'], resolve),
},
{
  path: '/Baiinfo/:id',
  name: 'Baiinfo',
  // route level code-splitting
  // this generates a separate chunk (about.[hash].js) for this route
  // which is lazy-loaded when the route is visited.
  component: (resolve) => require([/* webpackChunkName: "Baiinfo" */ '../components/Cust/Baiinfo.vue'], resolve),
},
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})




// 路由重定向bug修复
// 解决Vue-Router升级导致的Uncaught（in promise） navigation guard的问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}
export default router
